home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / objbase.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  31.0 KB  |  912 lines

  1. //+---------------------------------------------------------------------------
  2. //
  3. //  Microsoft Windows
  4. //  Copyright (C) Microsoft Corporation, 1992-1997.
  5. //
  6. //  File:       objbase.h
  7. //
  8. //  Contents:   Component object model defintions.
  9. //
  10. //----------------------------------------------------------------------------
  11. #pragma option push -b
  12.  
  13. #include <rpc.h>
  14. #include <rpcndr.h>
  15.  
  16. #if !defined( _OBJBASE_H_ )
  17. #define _OBJBASE_H_
  18.  
  19. #include <pshpack8.h>
  20.  
  21. #ifdef _MAC
  22. #ifndef _WLM_NOFORCE_LIBS
  23.  
  24. #ifdef _WLMDLL
  25.         #ifdef _DEBUG
  26.                 #pragma comment(lib, "oledlgd.lib")
  27.                 #pragma comment(lib, "msvcoled.lib")
  28.         #else
  29.                 #pragma comment(lib, "oledlg.lib")
  30.                 #pragma comment(lib, "msvcole.lib")
  31.         #endif
  32. #else
  33.         #ifdef _DEBUG
  34.                 #pragma comment(lib, "wlmoled.lib")
  35.                 #pragma comment(lib, "ole2uid.lib")
  36.         #else
  37.                 #pragma comment(lib, "wlmole.lib")
  38.                 #pragma comment(lib, "ole2ui.lib")
  39.         #endif
  40.         #pragma data_seg(".drectve")
  41.         static char _gszWlmOLEUIResourceDirective[] = "/macres:ole2ui.rsc";
  42.         #pragma data_seg()
  43. #endif
  44.  
  45. #pragma comment(lib, "uuid.lib")
  46.  
  47. #ifdef _DEBUG
  48.     #pragma comment(lib, "ole2d.lib")
  49.     #pragma comment(lib, "ole2autd.lib")
  50. #else
  51.     #pragma comment(lib, "ole2.lib")
  52.     #pragma comment(lib, "ole2auto.lib")
  53. #endif
  54.  
  55. #endif // !_WLM_NOFORCE_LIBS
  56. #endif // _MAC
  57.  
  58. #if 0
  59. // Component Object Model defines, and macros
  60.  
  61. #ifdef __cplusplus
  62.     #define EXTERN_C    extern "C"
  63. #else
  64.     #define EXTERN_C    extern
  65. #endif
  66.  
  67. #if defined(_WIN32) || defined(_MPPC_)
  68.  
  69. // Win32 doesn't support __export
  70.  
  71. #ifdef _68K_
  72. #define STDMETHODCALLTYPE       __cdecl
  73. #else
  74. #define STDMETHODCALLTYPE       __stdcall
  75. #endif
  76. #define STDMETHODVCALLTYPE      __cdecl
  77.  
  78. #define STDAPICALLTYPE          __stdcall
  79. #define STDAPIVCALLTYPE         __cdecl
  80.  
  81. #else
  82.  
  83. #define STDMETHODCALLTYPE       __export __stdcall
  84. #define STDMETHODVCALLTYPE      __export __cdecl
  85.  
  86. #define STDAPICALLTYPE          __export __stdcall
  87. #define STDAPIVCALLTYPE         __export __cdecl
  88.  
  89. #endif
  90.  
  91.  
  92. #define STDAPI                  EXTERN_C HRESULT STDAPICALLTYPE
  93. #define STDAPI_(type)           EXTERN_C type STDAPICALLTYPE
  94.  
  95. #define STDMETHODIMP            HRESULT STDMETHODCALLTYPE
  96. #define STDMETHODIMP_(type)     type STDMETHODCALLTYPE
  97.  
  98. // The 'V' versions allow Variable Argument lists.
  99.  
  100. #define STDAPIV                 EXTERN_C HRESULT STDAPIVCALLTYPE
  101. #define STDAPIV_(type)          EXTERN_C type STDAPIVCALLTYPE
  102.  
  103. #define STDMETHODIMPV           HRESULT STDMETHODVCALLTYPE
  104. #define STDMETHODIMPV_(type)    type STDMETHODVCALLTYPE
  105.  
  106. #endif
  107.  
  108. #ifdef _OLE32_
  109. #define WINOLEAPI        STDAPI
  110. #define WINOLEAPI_(type) STDAPI_(type)
  111. #else
  112.  
  113. #ifdef _68K_
  114. #ifndef REQUIRESAPPLEPASCAL
  115. #define WINOLEAPI        EXTERN_C DECLSPEC_IMPORT HRESULT PASCAL
  116. #define WINOLEAPI_(type) EXTERN_C DECLSPEC_IMPORT type PASCAL
  117. #else
  118. #define WINOLEAPI        EXTERN_C DECLSPEC_IMPORT PASCAL HRESULT
  119. #define WINOLEAPI_(type) EXTERN_C DECLSPEC_IMPORT PASCAL type
  120. #endif
  121. #else
  122. #define WINOLEAPI        EXTERN_C DECLSPEC_IMPORT HRESULT STDAPICALLTYPE
  123. #define WINOLEAPI_(type) EXTERN_C DECLSPEC_IMPORT type STDAPICALLTYPE
  124. #endif
  125.  
  126. #endif
  127.  
  128. /****** Interface Declaration ***********************************************/
  129.  
  130. /*
  131.  *      These are macros for declaring interfaces.  They exist so that
  132.  *      a single definition of the interface is simulataneously a proper
  133.  *      declaration of the interface structures (C++ abstract classes)
  134.  *      for both C and C++.
  135.  *
  136.  *      DECLARE_INTERFACE(iface) is used to declare an interface that does
  137.  *      not derive from a base interface.
  138.  *      DECLARE_INTERFACE_(iface, baseiface) is used to declare an interface
  139.  *      that does derive from a base interface.
  140.  *
  141.  *      By default if the source file has a .c extension the C version of
  142.  *      the interface declaratations will be expanded; if it has a .cpp
  143.  *      extension the C++ version will be expanded. if you want to force
  144.  *      the C version expansion even though the source file has a .cpp
  145.  *      extension, then define the macro "CINTERFACE".
  146.  *      eg.     cl -DCINTERFACE file.cpp
  147.  *
  148.  *      Example Interface declaration:
  149.  *
  150.  *          #undef  INTERFACE
  151.  *          #define INTERFACE   IClassFactory
  152.  *
  153.  *          DECLARE_INTERFACE_(IClassFactory, IUnknown)
  154.  *          {
  155.  *              // *** IUnknown methods ***
  156.  *              STDMETHOD(QueryInterface) (THIS_
  157.  *                                        REFIID riid,
  158.  *                                        LPVOID FAR* ppvObj) PURE;
  159.  *              STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  160.  *              STDMETHOD_(ULONG,Release) (THIS) PURE;
  161.  *
  162.  *              // *** IClassFactory methods ***
  163.  *              STDMETHOD(CreateInstance) (THIS_
  164.  *                                        LPUNKNOWN pUnkOuter,
  165.  *                                        REFIID riid,
  166.  *                                        LPVOID FAR* ppvObject) PURE;
  167.  *          };
  168.  *
  169.  *      Example C++ expansion:
  170.  *
  171.  *          struct FAR IClassFactory : public IUnknown
  172.  *          {
  173.  *              virtual HRESULT STDMETHODCALLTYPE QueryInterface(
  174.  *                                                  IID FAR& riid,
  175.  *                                                  LPVOID FAR* ppvObj) = 0;
  176.  *              virtual HRESULT STDMETHODCALLTYPE AddRef(void) = 0;
  177.  *              virtual HRESULT STDMETHODCALLTYPE Release(void) = 0;
  178.  *              virtual HRESULT STDMETHODCALLTYPE CreateInstance(
  179.  *                                              LPUNKNOWN pUnkOuter,
  180.  *                                              IID FAR& riid,
  181.  *                                              LPVOID FAR* ppvObject) = 0;
  182.  *          };
  183.  *
  184.  *          NOTE: Our documentation says '#define interface class' but we use
  185.  *          'struct' instead of 'class' to keep a lot of 'public:' lines
  186.  *          out of the interfaces.  The 'FAR' forces the 'this' pointers to
  187.  *          be far, which is what we need.
  188.  *
  189.  *      Example C expansion:
  190.  *
  191.  *          typedef struct IClassFactory
  192.  *          {
  193.  *              const struct IClassFactoryVtbl FAR* lpVtbl;
  194.  *          } IClassFactory;
  195.  *
  196.  *          typedef struct IClassFactoryVtbl IClassFactoryVtbl;
  197.  *
  198.  *          struct IClassFactoryVtbl
  199.  *          {
  200.  *              HRESULT (STDMETHODCALLTYPE * QueryInterface) (
  201.  *                                                  IClassFactory FAR* This,
  202.  *                                                  IID FAR* riid,
  203.  *                                                  LPVOID FAR* ppvObj) ;
  204.  *              HRESULT (STDMETHODCALLTYPE * AddRef) (IClassFactory FAR* This) ;
  205.  *              HRESULT (STDMETHODCALLTYPE * Release) (IClassFactory FAR* This) ;
  206.  *              HRESULT (STDMETHODCALLTYPE * CreateInstance) (
  207.  *                                                  IClassFactory FAR* This,
  208.  *                                                  LPUNKNOWN pUnkOuter,
  209.  *                                                  IID FAR* riid,
  210.  *                                                  LPVOID FAR* ppvObject);
  211.  *              HRESULT (STDMETHODCALLTYPE * LockServer) (
  212.  *                                                  IClassFactory FAR* This,
  213.  *                                                  BOOL fLock);
  214.  *          };
  215.  */
  216.  
  217. #if defined(__cplusplus) && !defined(CINTERFACE)
  218. //#define interface               struct FAR
  219. #if defined(_MSC_VER) && (_MSC_VER>=1100) && !defined(NO_NOVTABLE)
  220. #define interface struct __declspec(novtable)
  221. #else
  222. #define interface struct
  223. #endif
  224. #define STDMETHOD(method)       virtual HRESULT STDMETHODCALLTYPE method
  225. #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method
  226. #define PURE                    = 0
  227. #define THIS_
  228. #define THIS                    void
  229. #define DECLARE_INTERFACE(iface)    interface iface
  230. #define DECLARE_INTERFACE_(iface, baseiface)    interface iface : public baseiface
  231.  
  232.  
  233. #if !defined(BEGIN_INTERFACE)
  234. #if defined(_MPPC_)  && \
  235.     ( (defined(_MSC_VER) || defined(__SC__) || defined(__MWERKS__)) && \
  236.     !defined(NO_NULL_VTABLE_ENTRY) )
  237.    #define BEGIN_INTERFACE virtual void a() {}
  238.    #define END_INTERFACE
  239. #else
  240.    #define BEGIN_INTERFACE
  241.    #define END_INTERFACE
  242. #endif
  243. #endif
  244.  
  245. #else
  246.  
  247. #define interface               struct
  248.  
  249. #define STDMETHOD(method)       HRESULT (STDMETHODCALLTYPE * method)
  250. #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE * method)
  251.  
  252. #if !defined(BEGIN_INTERFACE)
  253. #if defined(_MPPC_)
  254.     #define BEGIN_INTERFACE       void    *b;
  255.     #define END_INTERFACE
  256. #else
  257.     #define BEGIN_INTERFACE
  258.     #define END_INTERFACE
  259. #endif
  260. #endif
  261.  
  262.  
  263. #define PURE
  264. #define THIS_                   INTERFACE FAR* This,
  265. #define THIS                    INTERFACE FAR* This
  266. #ifdef CONST_VTABLE
  267. #undef CONST_VTBL
  268. #define CONST_VTBL const
  269. #define DECLARE_INTERFACE(iface)    typedef interface iface { \
  270.                                     const struct iface##Vtbl FAR* lpVtbl; \
  271.                                 } iface; \
  272.                                 typedef const struct iface##Vtbl iface##Vtbl; \
  273.                                 const struct iface##Vtbl
  274. #else
  275. #undef CONST_VTBL
  276. #define CONST_VTBL
  277. #define DECLARE_INTERFACE(iface)    typedef interface iface { \
  278.                                     struct iface##Vtbl FAR* lpVtbl; \
  279.                                 } iface; \
  280.                                 typedef struct iface##Vtbl iface##Vtbl; \
  281.                                 struct iface##Vtbl
  282. #endif
  283. #define DECLARE_INTERFACE_(iface, baseiface)    DECLARE_INTERFACE(iface)
  284.  
  285. #endif
  286.  
  287.  
  288.  
  289.  
  290. /****** Additional basic types **********************************************/
  291.  
  292.  
  293. #ifndef FARSTRUCT
  294. #ifdef __cplusplus
  295. #define FARSTRUCT   FAR
  296. #else
  297. #define FARSTRUCT
  298. #endif  // __cplusplus
  299. #endif  // FARSTRUCT
  300.  
  301.  
  302.  
  303. #ifndef HUGEP
  304. #if defined(_WIN32) || defined(_MPPC_)
  305. #define HUGEP
  306. #else
  307. #define HUGEP __huge
  308. #endif // WIN32
  309. #endif // HUGEP
  310.  
  311.  
  312. #ifdef _MAC
  313. #if !defined(OLE2ANSI)
  314. #define OLE2ANSI
  315. #endif
  316. #endif
  317.  
  318. #include <stdlib.h>
  319.  
  320. #define LISet32(li, v) ((li).HighPart = (v) < 0 ? -1 : 0, (li).LowPart = (v))
  321.  
  322. #define ULISet32(li, v) ((li).HighPart = 0, (li).LowPart = (v))
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329. #define CLSCTX_INPROC           (CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER)
  330.  
  331. // With DCOM, CLSCTX_REMOTE_SERVER should be included
  332. #if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  333. #define CLSCTX_ALL              (CLSCTX_INPROC_SERVER| \
  334.                                  CLSCTX_INPROC_HANDLER| \
  335.                                  CLSCTX_LOCAL_SERVER| \
  336.                                  CLSCTX_REMOTE_SERVER)
  337.  
  338. #define CLSCTX_SERVER           (CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER|CLSCTX_REMOTE_SERVER)
  339. #else
  340. #define CLSCTX_ALL              (CLSCTX_INPROC_SERVER| \
  341.                                  CLSCTX_INPROC_HANDLER| \
  342.                                  CLSCTX_LOCAL_SERVER )
  343.  
  344. #define CLSCTX_SERVER           (CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER)
  345. #endif
  346.  
  347.  
  348. // class registration flags; passed to CoRegisterClassObject
  349. typedef enum tagREGCLS
  350. {
  351.     REGCLS_SINGLEUSE = 0,       // class object only generates one instance
  352.     REGCLS_MULTIPLEUSE = 1,     // same class object genereates multiple inst.
  353.                                 // and local automatically goes into inproc tbl.
  354.     REGCLS_MULTI_SEPARATE = 2,  // multiple use, but separate control over each
  355.                                 // context.
  356.     REGCLS_SUSPENDED      = 4,  // register is as suspended, will be activated
  357.                                 // when app calls CoResumeClassObjects
  358.     REGCLS_SURROGATE      = 8   // must be used when a surrogate process
  359.                                 // is registering a class object that will be
  360.                                 // loaded in the surrogate
  361. } REGCLS;
  362.  
  363. // interface marshaling definitions
  364. #define MARSHALINTERFACE_MIN 500 // minimum number of bytes for interface marshl
  365.  
  366.  
  367. //
  368. // Common typedefs for paramaters used in Storage API's, gleamed from storage.h
  369. // Also contains Storage error codes, which should be moved into the storage
  370. // idl files.
  371. //
  372.  
  373.  
  374. #define CWCSTORAGENAME 32
  375.  
  376. /* Storage instantiation modes */
  377. #define STGM_DIRECT             0x00000000L
  378. #define STGM_TRANSACTED         0x00010000L
  379. #define STGM_SIMPLE             0x08000000L
  380.  
  381. #define STGM_READ               0x00000000L
  382. #define STGM_WRITE              0x00000001L
  383. #define STGM_READWRITE          0x00000002L
  384.  
  385. #define STGM_SHARE_DENY_NONE    0x00000040L
  386. #define STGM_SHARE_DENY_READ    0x00000030L
  387. #define STGM_SHARE_DENY_WRITE   0x00000020L
  388. #define STGM_SHARE_EXCLUSIVE    0x00000010L
  389.  
  390. #define STGM_PRIORITY           0x00040000L
  391. #define STGM_DELETEONRELEASE    0x04000000L
  392. #if (WINVER >= 400)
  393. #define STGM_NOSCRATCH          0x00100000L
  394. #endif /* WINVER */
  395.  
  396. #define STGM_CREATE             0x00001000L
  397. #define STGM_CONVERT            0x00020000L
  398. #define STGM_FAILIFTHERE        0x00000000L
  399.  
  400. #define STGM_NOSNAPSHOT         0x00200000L
  401.  
  402. /*  flags for internet asyncronous and layout docfile */
  403. #define ASYNC_MODE_COMPATIBILITY    0x00000001L
  404. #define ASYNC_MODE_DEFAULT          0x00000000L
  405.  
  406. #define STGTY_REPEAT                0x00000100L
  407. #define STG_TOEND                   0xFFFFFFFFL
  408.  
  409. #define STG_LAYOUT_SEQUENTIAL       0x00000000L
  410. #define STG_LAYOUT_INTERLEAVED      0x00000001L
  411.  
  412.  
  413.  
  414.  
  415. /* here is where we pull in the MIDL generated headers for the interfaces */
  416. typedef interface    IRpcStubBuffer     IRpcStubBuffer;
  417. typedef interface    IRpcChannelBuffer  IRpcChannelBuffer;
  418.  
  419. #include <wtypes.h>
  420. #include <unknwn.h>
  421. #include <objidl.h>
  422.  
  423.  
  424. // macros to define byte pattern for a GUID.
  425. //      Example: DEFINE_GUID(GUID_XXX, a, b, c, ...);
  426. //
  427. // Each dll/exe must initialize the GUIDs once.  This is done in one of
  428. // two ways.  If you are not using precompiled headers for the file(s) which
  429. // initializes the GUIDs, define INITGUID before including objbase.h.  This
  430. // is how OLE builds the initialized versions of the GUIDs which are included
  431. // in ole2.lib.  The GUIDs in ole2.lib are all defined in the same text
  432. // segment GUID_TEXT.
  433. //
  434. // The alternative (which some versions of the compiler don't handle properly;
  435. // they wind up with the initialized GUIDs in a data, not a text segment),
  436. // is to use a precompiled version of objbase.h and then include initguid.h
  437. // after objbase.h followed by one or more of the guid defintion files.
  438.  
  439. #ifndef INITGUID
  440. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  441.     EXTERN_C const GUID FAR name
  442. #else
  443.  
  444. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  445.         EXTERN_C const GUID name \
  446.                 = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
  447. #endif // INITGUID
  448.  
  449. #define DEFINE_OLEGUID(name, l, w1, w2) \
  450.     DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
  451.  
  452. #ifdef _OLE32_
  453.  
  454.  
  455. // Faster (but makes code fatter) inline version...use sparingly
  456. #ifdef __cplusplus
  457. __inline BOOL  InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
  458. {
  459.    return (
  460.       ((PLONG) &rguid1)[0] == ((PLONG) &rguid2)[0] &&
  461.       ((PLONG) &rguid1)[1] == ((PLONG) &rguid2)[1] &&
  462.       ((PLONG) &rguid1)[2] == ((PLONG) &rguid2)[2] &&
  463.       ((PLONG) &rguid1)[3] == ((PLONG) &rguid2)[3]);
  464. }
  465. #else   // ! __cplusplus
  466. #define InlineIsEqualGUID(rguid1, rguid2)  \
  467.         (((PLONG) rguid1)[0] == ((PLONG) rguid2)[0] &&   \
  468.         ((PLONG) rguid1)[1] == ((PLONG) rguid2)[1] &&    \
  469.         ((PLONG) rguid1)[2] == ((PLONG) rguid2)[2] &&    \
  470.         ((PLONG) rguid1)[3] == ((PLONG) rguid2)[3])
  471. #endif  // __cplusplus
  472.  
  473. #ifdef _OLE32PRIV_
  474. BOOL _fastcall wIsEqualGUID(REFGUID rguid1, REFGUID rguid2);
  475. #define IsEqualGUID(rguid1, rguid2) wIsEqualGUID(rguid1, rguid2)
  476. #else
  477. #define IsEqualGUID(rguid1, rguid2) InlineIsEqualGUID(rguid1, rguid2)
  478. #endif  // _OLE32PRIV_
  479.  
  480. #else   // ! _OLE32_
  481. #ifdef __cplusplus
  482. __inline BOOL IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
  483. {
  484.     return !memcmp(&rguid1, &rguid2, sizeof(GUID));
  485. }
  486. #else   //  ! __cplusplus
  487. #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
  488. #endif  //  __cplusplus
  489. #endif  //  _OLE32_
  490.  
  491. #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
  492. #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
  493.  
  494. #ifdef __cplusplus
  495.  
  496. // because GUID is defined elsewhere in WIN32 land, the operator == and !=
  497. // are moved outside the class to global scope.
  498.  
  499. #ifdef _OLE32_
  500. __inline BOOL operator==(const GUID& guidOne, const GUID& guidOther)
  501. {
  502.     return IsEqualGUID(guidOne,guidOther);
  503. }
  504. #else   // !_OLE32_
  505. __inline BOOL operator==(const GUID& guidOne, const GUID& guidOther)
  506. {
  507. #ifdef _WIN32
  508.     return !memcmp(&guidOne,&guidOther,sizeof(GUID));
  509. #else
  510.     return !_fmemcmp(&guidOne,&guidOther,sizeof(GUID)); }
  511. #endif
  512. }
  513. #endif // _OLE32_
  514.  
  515. __inline BOOL operator!=(const GUID& guidOne, const GUID& guidOther)
  516. {
  517.     return !(guidOne == guidOther);
  518. }
  519.  
  520. #endif // __cpluscplus
  521.  
  522.  
  523. #ifndef INITGUID
  524. #include <cguid.h>
  525. #endif
  526.  
  527. // COM initialization flags; passed to CoInitialize.
  528. typedef enum tagCOINIT
  529. {
  530.   COINIT_APARTMENTTHREADED  = 0x2,      // Apartment model
  531.  
  532. #if  (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  533.   // These constants are only valid on Windows NT 4.0
  534.   COINIT_MULTITHREADED      = 0x0,      // OLE calls objects on any thread.
  535.   COINIT_DISABLE_OLE1DDE    = 0x4,      // Don't use DDE for Ole1 support.
  536.   COINIT_SPEED_OVER_MEMORY  = 0x8,      // Trade memory for speed.
  537. #endif // DCOM
  538. } COINIT;
  539.  
  540.  
  541.  
  542.  
  543.  
  544. /****** STD Object API Prototypes *****************************************/
  545.  
  546. WINOLEAPI_(DWORD) CoBuildVersion( VOID );
  547.  
  548. /* init/uninit */
  549.  
  550. WINOLEAPI  CoInitialize(LPVOID pvReserved);
  551. WINOLEAPI_(void)  CoUninitialize(void);
  552. WINOLEAPI  CoGetMalloc(DWORD dwMemContext, LPMALLOC FAR* ppMalloc);
  553. WINOLEAPI_(DWORD) CoGetCurrentProcess(void);
  554. WINOLEAPI  CoRegisterMallocSpy(LPMALLOCSPY pMallocSpy);
  555. WINOLEAPI  CoRevokeMallocSpy(void);
  556. WINOLEAPI  CoCreateStandardMalloc(DWORD memctx, IMalloc FAR* FAR* ppMalloc);
  557.  
  558. #if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  559. WINOLEAPI  CoInitializeEx(LPVOID pvReserved, DWORD dwCoInit);
  560. #endif // DCOM
  561.  
  562. #if DBG == 1
  563. WINOLEAPI_(ULONG) DebugCoGetRpcFault( void );
  564. WINOLEAPI_(void) DebugCoSetRpcFault( ULONG );
  565. #endif
  566.  
  567. /* register/revoke/get class objects */
  568.  
  569. WINOLEAPI  CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, LPVOID pvReserved,
  570.                     REFIID riid, LPVOID FAR* ppv);
  571. WINOLEAPI  CoRegisterClassObject(REFCLSID rclsid, LPUNKNOWN pUnk,
  572.                     DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister);
  573. WINOLEAPI  CoRevokeClassObject(DWORD dwRegister);
  574. WINOLEAPI  CoResumeClassObjects(void);
  575. WINOLEAPI  CoSuspendClassObjects(void);
  576. WINOLEAPI_(ULONG) CoAddRefServerProcess(void);
  577. WINOLEAPI_(ULONG) CoReleaseServerProcess(void);
  578. WINOLEAPI  CoGetPSClsid(REFIID riid, CLSID *pClsid);
  579. WINOLEAPI  CoRegisterPSClsid(REFIID riid, REFCLSID rclsid);
  580.  
  581. #if (_WIN32_WINNT >= 0x0402 )
  582. // Registering surrogate processes
  583. WINOLEAPI  CoRegisterSurrogate(LPSURROGATE pSurrogate);
  584. #endif
  585.  
  586. /* marshaling interface pointers */
  587.  
  588. WINOLEAPI CoGetMarshalSizeMax(ULONG *pulSize, REFIID riid, LPUNKNOWN pUnk,
  589.                     DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags);
  590. WINOLEAPI CoMarshalInterface(LPSTREAM pStm, REFIID riid, LPUNKNOWN pUnk,
  591.                     DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags);
  592. WINOLEAPI CoUnmarshalInterface(LPSTREAM pStm, REFIID riid, LPVOID FAR* ppv);
  593. WINOLEAPI CoMarshalHresult(LPSTREAM pstm, HRESULT hresult);
  594. WINOLEAPI CoUnmarshalHresult(LPSTREAM pstm, HRESULT FAR * phresult);
  595. WINOLEAPI CoReleaseMarshalData(LPSTREAM pStm);
  596. WINOLEAPI CoDisconnectObject(LPUNKNOWN pUnk, DWORD dwReserved);
  597. WINOLEAPI CoLockObjectExternal(LPUNKNOWN pUnk, BOOL fLock, BOOL fLastUnlockReleases);
  598. WINOLEAPI CoGetStandardMarshal(REFIID riid, LPUNKNOWN pUnk,
  599.                     DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags,
  600.                     LPMARSHAL FAR* ppMarshal);
  601.  
  602.  
  603. WINOLEAPI CoGetStdMarshalEx(LPUNKNOWN pUnkOuter, DWORD smexflags,
  604.                 LPUNKNOWN FAR* ppUnkInner);
  605.  
  606. /* flags for CoGetStdMarshalEx */
  607. typedef enum tagSTDMSHLFLAGS
  608. {
  609.     SMEXF_SERVER     = 0x01,       // server side aggregated std marshaler
  610.     SMEXF_HANDLER    = 0x02        // client side (handler) agg std marshaler
  611. } STDMSHLFLAGS;
  612.  
  613.  
  614. WINOLEAPI_(BOOL) CoIsHandlerConnected(LPUNKNOWN pUnk);
  615. WINOLEAPI_(BOOL) CoHasStrongExternalConnections(LPUNKNOWN pUnk);
  616.  
  617. // Apartment model inter-thread interface passing helpers
  618. WINOLEAPI CoMarshalInterThreadInterfaceInStream(REFIID riid, LPUNKNOWN pUnk,
  619.                     LPSTREAM *ppStm);
  620.  
  621. WINOLEAPI CoGetInterfaceAndReleaseStream(LPSTREAM pStm, REFIID iid,
  622.                     LPVOID FAR* ppv);
  623.  
  624. WINOLEAPI CoCreateFreeThreadedMarshaler(LPUNKNOWN  punkOuter,
  625.                     LPUNKNOWN *ppunkMarshal);
  626.  
  627. /* dll loading helpers; keeps track of ref counts and unloads all on exit */
  628.  
  629. WINOLEAPI_(HINSTANCE) CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree);
  630. WINOLEAPI_(void) CoFreeLibrary(HINSTANCE hInst);
  631. WINOLEAPI_(void) CoFreeAllLibraries(void);
  632. WINOLEAPI_(void) CoFreeUnusedLibraries(void);
  633.  
  634.  
  635. #if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  636.  
  637. /* Call Security. */
  638.  
  639. WINOLEAPI CoInitializeSecurity(
  640.                     PSECURITY_DESCRIPTOR         pSecDesc,
  641.                     LONG                         cAuthSvc,
  642.                     SOLE_AUTHENTICATION_SERVICE *asAuthSvc,
  643.                     void                        *pReserved1,
  644.                     DWORD                        dwAuthnLevel,
  645.                     DWORD                        dwImpLevel,
  646.                     void                        *pReserved2,
  647.                     DWORD                        dwCapabilities,
  648.                     void                        *pReserved3 );
  649. WINOLEAPI CoGetCallContext( REFIID riid, void **ppInterface );
  650. WINOLEAPI CoQueryProxyBlanket(
  651.     IUnknown                  *pProxy,
  652.     DWORD                     *pwAuthnSvc,
  653.     DWORD                     *pAuthzSvc,
  654.     OLECHAR                  **pServerPrincName,
  655.     DWORD                     *pAuthnLevel,
  656.     DWORD                     *pImpLevel,
  657.     RPC_AUTH_IDENTITY_HANDLE  *pAuthInfo,
  658.     DWORD                     *pCapabilites );
  659. WINOLEAPI CoSetProxyBlanket(
  660.     IUnknown                 *pProxy,
  661.     DWORD                     dwAuthnSvc,
  662.     DWORD                     dwAuthzSvc,
  663.     OLECHAR                  *pServerPrincName,
  664.     DWORD                     dwAuthnLevel,
  665.     DWORD                     dwImpLevel,
  666.     RPC_AUTH_IDENTITY_HANDLE  pAuthInfo,
  667.     DWORD                     dwCapabilities );
  668. WINOLEAPI CoCopyProxy(
  669.     IUnknown    *pProxy,
  670.     IUnknown   **ppCopy );
  671. WINOLEAPI CoQueryClientBlanket(
  672.     DWORD             *pAuthnSvc,
  673.     DWORD             *pAuthzSvc,
  674.     OLECHAR          **pServerPrincName,
  675.     DWORD             *pAuthnLevel,
  676.     DWORD             *pImpLevel,
  677.     RPC_AUTHZ_HANDLE  *pPrivs,
  678.     DWORD             *pCapabilities );
  679. WINOLEAPI CoImpersonateClient();
  680. WINOLEAPI CoRevertToSelf();
  681. WINOLEAPI CoQueryAuthenticationServices(
  682.     DWORD *pcAuthSvc,
  683.     SOLE_AUTHENTICATION_SERVICE **asAuthSvc );
  684. WINOLEAPI CoSwitchCallContext( IUnknown *pNewObject, IUnknown **ppOldObject );
  685.  
  686. #define COM_RIGHTS_EXECUTE 1
  687.  
  688. #endif // DCOM
  689.  
  690. /* helper for creating instances */
  691.  
  692. WINOLEAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter,
  693.                     DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv);
  694.  
  695.  
  696. #if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  697.  
  698. WINOLEAPI CoGetInstanceFromFile(
  699.     COSERVERINFO *              pServerInfo,
  700.     CLSID       *               pClsid,
  701.     IUnknown    *               punkOuter, // only relevant locally
  702.     DWORD                       dwClsCtx,
  703.     DWORD                       grfMode,
  704.     OLECHAR *                   pwszName,
  705.     DWORD                       dwCount,
  706.     MULTI_QI        *           pResults );
  707.  
  708. WINOLEAPI CoGetInstanceFromIStorage(
  709.     COSERVERINFO *              pServerInfo,
  710.     CLSID       *               pClsid,
  711.     IUnknown    *               punkOuter, // only relevant locally
  712.     DWORD                       dwClsCtx,
  713.     struct IStorage *           pstg,
  714.     DWORD                       dwCount,
  715.     MULTI_QI        *           pResults );
  716.  
  717. WINOLEAPI CoCreateInstanceEx(
  718.     REFCLSID                    Clsid,
  719.     IUnknown    *               punkOuter, // only relevant locally
  720.     DWORD                       dwClsCtx,
  721.     COSERVERINFO *              pServerInfo,
  722.     DWORD                       dwCount,
  723.     MULTI_QI        *           pResults );
  724.  
  725. #endif // DCOM
  726.  
  727.  
  728. /* other helpers */
  729.  
  730. WINOLEAPI StringFromCLSID(REFCLSID rclsid, LPOLESTR FAR* lplpsz);
  731. WINOLEAPI CLSIDFromString(LPOLESTR lpsz, LPCLSID pclsid);
  732. WINOLEAPI StringFromIID(REFIID rclsid, LPOLESTR FAR* lplpsz);
  733. WINOLEAPI IIDFromString(LPOLESTR lpsz, LPIID lpiid);
  734. WINOLEAPI_(BOOL) CoIsOle1Class(REFCLSID rclsid);
  735. WINOLEAPI ProgIDFromCLSID (REFCLSID clsid, LPOLESTR FAR* lplpszProgID);
  736. WINOLEAPI CLSIDFromProgID (LPCOLESTR lpszProgID, LPCLSID lpclsid);
  737. WINOLEAPI_(int) StringFromGUID2(REFGUID rguid, LPOLESTR lpsz, int cbMax);
  738.  
  739. WINOLEAPI CoCreateGuid(GUID FAR *pguid);
  740.  
  741. WINOLEAPI_(BOOL) CoFileTimeToDosDateTime(
  742.                  FILETIME FAR* lpFileTime, LPWORD lpDosDate, LPWORD lpDosTime);
  743. WINOLEAPI_(BOOL) CoDosDateTimeToFileTime(
  744.                        WORD nDosDate, WORD nDosTime, FILETIME FAR* lpFileTime);
  745. WINOLEAPI  CoFileTimeNow( FILETIME FAR* lpFileTime );
  746.  
  747.  
  748. WINOLEAPI CoRegisterMessageFilter( LPMESSAGEFILTER lpMessageFilter,
  749.                                 LPMESSAGEFILTER FAR* lplpMessageFilter );
  750.  
  751. #if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  752. WINOLEAPI CoRegisterChannelHook( REFGUID ExtensionUuid, IChannelHook *pChannelHook );
  753. #endif // DCOM
  754.  
  755.  
  756. /* TreatAs APIS */
  757.  
  758. WINOLEAPI CoGetTreatAsClass(REFCLSID clsidOld, LPCLSID pClsidNew);
  759. WINOLEAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew);
  760.  
  761.  
  762. /* the server dlls must define their DllGetClassObject and DllCanUnloadNow
  763.  * to match these; the typedefs are located here to ensure all are changed at
  764.  * the same time.
  765.  */
  766.  
  767. //#ifdef _MAC
  768. //typedef STDAPICALLTYPE HRESULT (* LPFNGETCLASSOBJECT) (REFCLSID, REFIID, LPVOID *);
  769. //#else
  770. typedef HRESULT (STDAPICALLTYPE * LPFNGETCLASSOBJECT) (REFCLSID, REFIID, LPVOID *);
  771. //#endif
  772.  
  773. //#ifdef _MAC
  774. //typedef STDAPICALLTYPE HRESULT (* LPFNCANUNLOADNOW)(void);
  775. //#else
  776. typedef HRESULT (STDAPICALLTYPE * LPFNCANUNLOADNOW)(void);
  777. //#endif
  778.  
  779. STDAPI  DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID FAR* ppv);
  780.  
  781. STDAPI  DllCanUnloadNow(void);
  782.  
  783.  
  784. /****** Default Memory Allocation ******************************************/
  785. WINOLEAPI_(LPVOID) CoTaskMemAlloc(ULONG cb);
  786. WINOLEAPI_(LPVOID) CoTaskMemRealloc(LPVOID pv, ULONG cb);
  787. WINOLEAPI_(void)   CoTaskMemFree(LPVOID pv);
  788.  
  789. /****** DV APIs ***********************************************************/
  790.  
  791.  
  792. WINOLEAPI CreateDataAdviseHolder(LPDATAADVISEHOLDER FAR* ppDAHolder);
  793.  
  794. WINOLEAPI CreateDataCache(LPUNKNOWN pUnkOuter, REFCLSID rclsid,
  795.                                         REFIID iid, LPVOID FAR* ppv);
  796.  
  797.  
  798.  
  799.  
  800. /****** Storage API Prototypes ********************************************/
  801.  
  802.  
  803. WINOLEAPI StgCreateDocfile(const OLECHAR FAR* pwcsName,
  804.             DWORD grfMode,
  805.             DWORD reserved,
  806.             IStorage FAR * FAR *ppstgOpen);
  807.  
  808. WINOLEAPI StgCreateDocfileOnILockBytes(ILockBytes FAR *plkbyt,
  809.                     DWORD grfMode,
  810.                     DWORD reserved,
  811.                     IStorage FAR * FAR *ppstgOpen);
  812.  
  813. WINOLEAPI StgOpenStorage(const OLECHAR FAR* pwcsName,
  814.               IStorage FAR *pstgPriority,
  815.               DWORD grfMode,
  816.               SNB snbExclude,
  817.               DWORD reserved,
  818.               IStorage FAR * FAR *ppstgOpen);
  819. WINOLEAPI StgOpenStorageOnILockBytes(ILockBytes FAR *plkbyt,
  820.                   IStorage FAR *pstgPriority,
  821.                   DWORD grfMode,
  822.                   SNB snbExclude,
  823.                   DWORD reserved,
  824.                   IStorage FAR * FAR *ppstgOpen);
  825.  
  826. WINOLEAPI StgIsStorageFile(const OLECHAR FAR* pwcsName);
  827. WINOLEAPI StgIsStorageILockBytes(ILockBytes FAR* plkbyt);
  828.  
  829. WINOLEAPI StgSetTimes(OLECHAR const FAR* lpszName,
  830.                    FILETIME const FAR* pctime,
  831.                    FILETIME const FAR* patime,
  832.                    FILETIME const FAR* pmtime);
  833.  
  834. WINOLEAPI StgOpenAsyncDocfileOnIFillLockBytes( IFillLockBytes *pflb,
  835.              DWORD grfMode,
  836.              DWORD asyncFlags,
  837.              IStorage **ppstgOpen);
  838.  
  839. WINOLEAPI StgGetIFillLockBytesOnILockBytes( ILockBytes *pilb,
  840.              IFillLockBytes **ppflb);
  841.  
  842. WINOLEAPI StgGetIFillLockBytesOnFile(OLECHAR const *pwcsName,
  843.              IFillLockBytes **ppflb);
  844.  
  845.  
  846. WINOLEAPI StgOpenLayoutDocfile(OLECHAR const *pwcsDfName,
  847.              DWORD grfMode,
  848.              DWORD reserved,
  849.              IStorage **ppstgOpen);
  850.  
  851. WINOLEAPI StgCreateStorageEx (const WCHAR* pwcsName,
  852.             DWORD grfMode,
  853.             DWORD stgfmt,              // enum
  854.             DWORD grfAttrs,             // reserved
  855.             void * reserved1,
  856.             void * reserved2,
  857.             REFIID riid,
  858.             void ** ppObjectOpen);
  859.  
  860. WINOLEAPI StgOpenStorageEx (const WCHAR* pwcsName,
  861.             DWORD grfMode,
  862.             DWORD stgfmt,              // enum
  863.             DWORD grfAttrs,             // reserved
  864.             void * reserved1,
  865.             void * reserved2,
  866.             REFIID riid,
  867.             void ** ppObjectOpen);
  868.  
  869.  
  870. //
  871. //  Moniker APIs
  872. //
  873.  
  874. WINOLEAPI  BindMoniker(LPMONIKER pmk, DWORD grfOpt, REFIID iidResult, LPVOID FAR* ppvResult);
  875.  
  876. WINOLEAPI  CoInstall(
  877.     IBindCtx     * pbc,
  878.     DWORD          dwFlags,
  879.     uCLSSPEC     * pClassSpec,
  880.     QUERYCONTEXT * pQuery,
  881.     LPWSTR         pszCodeBase);
  882.  
  883. WINOLEAPI  CoGetObject(LPCWSTR pszName, BIND_OPTS *pBindOptions, REFIID riid, void **ppv);
  884. WINOLEAPI  MkParseDisplayName(LPBC pbc, LPCOLESTR szUserName,
  885.                 ULONG FAR * pchEaten, LPMONIKER FAR * ppmk);
  886. WINOLEAPI  MonikerRelativePathTo(LPMONIKER pmkSrc, LPMONIKER pmkDest, LPMONIKER
  887.                 FAR* ppmkRelPath, BOOL dwReserved);
  888. WINOLEAPI  MonikerCommonPrefixWith(LPMONIKER pmkThis, LPMONIKER pmkOther,
  889.                 LPMONIKER FAR* ppmkCommon);
  890. WINOLEAPI  CreateBindCtx(DWORD reserved, LPBC FAR* ppbc);
  891. WINOLEAPI  CreateGenericComposite(LPMONIKER pmkFirst, LPMONIKER pmkRest,
  892.     LPMONIKER FAR* ppmkComposite);
  893. WINOLEAPI  GetClassFile (LPCOLESTR szFilename, CLSID FAR* pclsid);
  894.  
  895. WINOLEAPI  CreateClassMoniker(REFCLSID rclsid, LPMONIKER FAR* ppmk);
  896.  
  897. WINOLEAPI  CreateFileMoniker(LPCOLESTR lpszPathName, LPMONIKER FAR* ppmk);
  898.  
  899. WINOLEAPI  CreateItemMoniker(LPCOLESTR lpszDelim, LPCOLESTR lpszItem,
  900.     LPMONIKER FAR* ppmk);
  901. WINOLEAPI  CreateAntiMoniker(LPMONIKER FAR* ppmk);
  902. WINOLEAPI  CreatePointerMoniker(LPUNKNOWN punk, LPMONIKER FAR* ppmk);
  903.  
  904. WINOLEAPI  GetRunningObjectTable( DWORD reserved, LPRUNNINGOBJECTTABLE FAR* pprot);
  905.  
  906. #ifndef RC_INVOKED
  907. #include <poppack.h>
  908. #endif // RC_INVOKED
  909.  
  910. #endif     // __OBJBASE_H__
  911. #pragma option pop
  912.